package eightDataType;

/**
 * @author Ajie
 * @date 11/19/24
 * @function
 */
public class StringSplitDemo {
    public static void main(String[] args) {
        String str = "苹果,香蕉,橘子,葡萄";//0:苹果 1:香蕉 2:橘子 3:葡萄
//        String str = "苹果";//0 苹果
//        String str = "苹果,,";//0 苹果
        String[] fruits = str.split(",");

        for (int i = 0; i < fruits.length; i++) {
            System.out.println(i+":"+fruits[i]);
        }
    }

}
